package gmusic.command;

import gmusic.ma.services.impl.MetalArchivesServicesImpl;

import java.io.OutputStreamWriter;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

public class ExporterMAArtist implements CommandExport {

	private final static Logger log = Logger.getLogger(ExporterMAArtist.class);

	public void execute(HttpServletRequest req, HttpServletResponse res)
			throws Exception {

		long amaid = Long.parseLong(req.getParameter("amaid"));
		log.info("Export de l'artist MA : " + amaid);
		res.setContentType("text/plain; charset=UTF-8");
		res.setHeader("Content-Disposition", "attachment; filename=\"export_"
				+ amaid + ".maexp\"");
		PrintWriter out = new PrintWriter(new OutputStreamWriter(res
				.getOutputStream(), "UTF8"), true);

		out
				.write(MetalArchivesServicesImpl.getInstance().exportMAArtist(
						amaid));
		out.flush();
		out.close();
	}
}
